package com.chillis.standings.tests.domain;

import android.test.AndroidTestCase;
import com.chillis.standings.domain.table.Table;
import com.chillis.standings.domain.table.TablesFactory;
import static com.chillis.standings.domain.table.TableSettings.Format;

public class TablesFactoryTest extends AndroidTestCase {
   public void testCreate() throws Exception {
      for (Format format : Format.values()) {
         String string = format.toString(getContext());
         Format.fromString(getContext(), string);
      }
   }

   public void testCreateRoundTable() throws Exception {
      Table table = TablesFactory.createRoundTable(0);
      assertEquals(table.stages().size(), 0);

      table = TablesFactory.createRoundTable(1);
      assertEquals(table.stages().size(), 0);

      table = TablesFactory.createRoundTable(2);
      assertEquals(table.stages().size(), 1);

      table = TablesFactory.createRoundTable(8);
      assertEquals(table.stages().size(), 7);

      table = TablesFactory.createRoundTable(56);
      assertEquals(table.stages().size(), 55);
   }

   public void testCreateOlympic() throws Exception {
      Table table = TablesFactory.createOlympic(0);
      assertEquals(table.stages().size(), 0);

      table = TablesFactory.createOlympic(1);
      assertEquals(table.stages().size(), 0);

      table = TablesFactory.createOlympic(2);
      assertEquals(table.stages().size(), 1);

      table = TablesFactory.createOlympic(8);
      assertEquals(table.stages().size(), 3);

      table = TablesFactory.createOlympic(32);
      assertEquals(table.stages().size(), 5);
   }
}
